<style lang="sass" scoped>
    .logo{
        margin:140px auto 0;
        display:block;
    }
    .title{
        margin-top:150px;
        justify-content: center;
        align-items:center;
        .head-img{
            width:60px;
            height:60px;
            display: block;
            margin-right:30px;
        }
        .text{
            font-size:30px;
            max-width: 500px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    }
    .login{
        width:500px;
        margin:50px auto;
        .group{
            margin-bottom:30px;
            .label{
                width:50px;
                font-size:24px;
            }
            input{
                flex:1;
                border:1px solid #ccc;
                background:#fff;
                padding:10px;
                border-radius: 10px;
                font-size:24px;
            }
        }
    }
    .login-btn{
        width:160px;
        height:60px;
        line-height:60px;
        text-align:center;
        background:rgb(255, 95, 95);
        color:#fff;
        font-size:24px;
        border-radius:20px;
        margin:0 auto;
    }
</style>
<template>
    <div class="container">
        <div class="title flex">
            <img class="head-img" src="../../assets/images/user2.png" alt="">
            <div class="text">123</div>
        </div>
        <div class="login">
            <div class="group flex">
                <input v-model.trim="post.oldPwd" type="password" placeholder="请输入旧密码">
            </div>
            <div class="group flex">
                <input v-model.trim="post.newPwd" type="password" placeholder="请输入新密码">
            </div>
            <div class="group flex">
                <input v-model.trim="post.newPwd2" type="password" placeholder="请再次输入新密码">
            </div>
            <div @click="regis()" class="login-btn">确定</div>
        </div>
    </div>
</template>
<script>
    export default {
        components: {
        },
        data() {
            return {
                post:{
                    oldPwd:'',//	Y	string	旧密码
                    newPwd:'',//	Y	string	新密码
                    newPwd2:'',//	Y	string	新密码
                }
            };
        },
        watch:{
        },
        created(){

        },
        mounted() {
            this.$nextTick(() => {
                 
            });
        },
        methods: {
            regis(){
                let param = JSON.parse(JSON.stringify(this.post));
                if(param.oldPwd===''){
                    popup.alert({content:'请输入旧密码'})
                    return;
                }
                if(param.newPwd===''){
                    popup.alert({content:'请输入新密码'})
                    return;
                }
                if(param.newPwd2===''){
                    popup.alert({content:'请再次输入新密码'})
                    return;
                }
                if(param.newPwd2&&param.newPwd2===''){
                    popup.alert({content:'两次输入的密码不一致，请重新输入！'})
                    return;
                }
                util.ajax({
                    url:config.baseApi + 'bookMall-dms/api/user/modifyPwd',
                    data:param,
                    success:(data=>{
                        popup.alert({
                            content:'修改成功！',
                            yes:()=>{
                                util.setCookie('dmsToken','',7);
                                util.setCookie('userMsg','');
                                router.replace({name:'login'});
                            }
                        })
                    })
                })
            }
        },
        
    };
</script>